package bz;

public class Customer extends Thread {

//    BaoZi bz = new BaoZi();
//
//    public Customer(BaoZi bz,String name) {
//        super(name);
//        this.bz = bz;
//    }
//
//    public Customer() {
//    }

    @Override
    public void run() {

        while (true) {
            synchronized (BaoZi.class) {
                while (BaoZi.num == 0) {
                    try {
                        BaoZi.class.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                BaoZi.num--;
                System.out.println(getName() + "顾客吃掉一个包子，还剩" + BaoZi.num + "个");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                BaoZi.class.notifyAll();

            }
        }
    }
}